#include "FileSystem.h"
#include "FoldExpression.h"
#include "If.h"
#include "InlineVariable.h"
#include <functional>
#include <iostream>

using namespace std;

#define WITH_NAME(func) #func, func

template <typename F, typename... Args>
void test(const string& name, F&& func, Args... args)
{
    cout << ">>>> Test on [" << name << "]" << endl;
    auto f = std::bind(std::forward<F>(func), std::forward<Args>(args)...);
    string result = "PASS";
    try {
        f();
    } catch (std::system_error& e) {
        result = "FAILED";
        cout << e.what() << endl;
    } catch (...) {
        result = "FAILED";
        cout << "Unknown error" << endl;
    }
    cout << "---- Result [" << result << "]" << endl;
}

int main(int, char**)
{
    test(WITH_NAME(structuredBindings));
    test(WITH_NAME(nestedNamespaces));
    test(WITH_NAME(captureThisInLambda));
    test(WITH_NAME(constexprLambda));
    test(WITH_NAME(attrFallthrough));
    test(WITH_NAME(attrNodiscard));
    test(WITH_NAME(attrMaybeunused));
    test(WITH_NAME(hasInclude));

    test(WITH_NAME(getCurrentPath));
    test(WITH_NAME(getFileSize));
    test(WITH_NAME(createDirectory));
    test(WITH_NAME(copyFiles));
    test(WITH_NAME(renameFile));

    test(WITH_NAME(foldExpression));

    test(WITH_NAME(ifWithConstexpr));
    test(WITH_NAME(ifWithInitializer));
    test(WITH_NAME(switchWithInitializer));

    test(WITH_NAME(inlineVariable));
}
